home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / -archivi / -recent2 / amicad_2.00.lha / AmiCAD / ARexx / ImportTexte.AmiCAD < prev    next >
Text File  |  1999-02-21  |  2KB  |  85 lines

  1. /* Importation d'un texte dans une zone rectangulaire
  2.    26 avril 1998: version 1.00
  3.    3 Février 1999: version 1.01 (correction bug guillemets + gestion ligne)
  4.    21 février 1999: version 1.02 (modif appel REQFILE)
  5.    $VER: ImportTexte 1.02 (© R.Florac, 21 février 1999)
  6.    Bug: ne gère pas les échelles et le mode placement courants */
  7.  
  8. options results
  9.  
  10. signal on error
  11. signal on syntax
  12.  
  13. 'FIRSTSEL'; obj=result
  14. if obj>0 then do
  15.     'TYPE('obj')'
  16.     if result=22 then do
  17.     'NEXTSEL('obj')'
  18.     if result=0 then do
  19.         'COORDS('obj')';
  20.         PARSE VAR result x0 ',' y0 ',' x1 ',' y1
  21.         xg=minima(x0,x1); xd=maxima(x0,x1)
  22.         yh=minima(y0,y1); yb=maxima(y0,y1)
  23.         'REQFILE("Nom du fichier texte?", "Travail:texte/ASCII", "")'; fichier=result
  24.         y0=yh
  25.         if fichier ~= "" then do
  26.         if open(file, fichier, 'R') then do
  27.             y0=y0+10
  28.             'SAVEALL(-1)'
  29.             do while y0 < yb
  30.             ligne=readln(file)
  31.             if ligne ~= "" then do
  32.                 ligne=translate(ligne,"        ",'09'x)
  33.                 'WRITE("'doublage_guillemets(ligne)'",'xg','y0')'; e=result
  34.                 if e=0 then do
  35.                 'REQUEST("Placement du texte"+CHR(10)+"'ligne'"+CHR(10)+"impossible."+CHR(10)+"Voulez-vous continuer?")'
  36.                 if result=0 then leave
  37.                 end
  38.                 y0=y0+10
  39.             end
  40.             if eof(file) then leave
  41.             end
  42.             close(file)
  43.         end
  44.         end
  45.         exit
  46.     end
  47.     end
  48. end
  49.  
  50. 'MESSAGE("Créez et sélectionnez"+CHR(10)+"d''abord le rectangle"+CHR(10)+"dans lequel doit"+CHR(10)+"être placé le texte")'
  51.  
  52. exit
  53.  
  54. minima: procedure
  55.     parse arg v1,v2
  56.     if v1<v2 then return v1
  57.     return v2
  58. end
  59.  
  60. maxima: procedure
  61.     parse arg v1,v2
  62.     if v1>v2 then return v1
  63.     return v2
  64. end
  65.  
  66. doublage_guillemets: procedure
  67.     parse arg chaine
  68.     t=''
  69.     do i=1 to length(chaine)
  70.     c = substr(chaine,i,1)
  71.     if c='"' then c=c||'"'
  72.     t=t||c
  73.     end
  74.     return t
  75.  
  76. /* Traitement des erreurs, interruption du programme */
  77. syntax:
  78. erreur=RC
  79. 'MESSAGE("Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  80. exit
  81.  
  82. error:
  83. 'MESSAGE("Erreur en ligne 'SIGL'")'
  84. exit
  85.